package org.jsbd.boss.dao.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.jsbd.boss.common.DataGridModel;
import org.jsbd.boss.dao.IUserIncrDAO;
import org.jsbd.boss.domian.statistics.UserClientInfoUseRatio;
import org.jsbd.boss.domian.statistics.UserClientinfoDay;
import org.jsbd.boss.domian.statistics.UserIncrVO;
import org.springframework.stereotype.Repository;

@Repository("userIncrDao")
public class UserIncrDAOImpl extends CrackStatisticsBaseDao implements IUserIncrDAO {

	@Override
	public Map<String, Object> selectIncrUserWithPage(DataGridModel page, UserIncrVO userIncrVO) {
		userIncrVO = (userIncrVO == null ? new UserIncrVO() : userIncrVO);
		userIncrVO.setPageInfo(page);
	    Map<String, Object> results = new HashMap<String, Object>();
	    results.put("rows", super.queryForList("qy_user_incr.SELECT_INCR_USER_LIST", userIncrVO));
	    results.put("total", super.queryForCount("qy_user_incr.SELECT_INCR_USER_COUNT", userIncrVO));
	    return results;
	}

	@Override
	public List<String> selectAnalyzeDataxAxis(String startTime) {
		return super.queryForList("qy_user_incr.SELECT_ANALYZE_DATA_XAXIS", startTime);
	}

	@Override
	public List<Integer> selectAnalyzeDatayAxis(String startTime, Integer type) {
		Map<String, Object> param = new HashMap<String, Object>();
		param.put("startTime", startTime);
		param.put("type", type);
		return super.queryForList("qy_user_incr.SELECT_ANALYZE_DATA_YAXIS", param);
	}

	@Override
	public List<UserClientinfoDay> selectAnalyzeDataPie(String startTime) {
		return super.queryForList("qy_user_incr.SELECT_ANALYZE_DATA_PIE", startTime);
	}

	@Override
	public List<String> selectUseRateDataxAxis(String startTime) {
		return super.queryForList("qy_user_incr.SELECT_USE_RATE_DATA_XAXIS", startTime);
	}

	@Override
	public List<UserClientInfoUseRatio> selectUseRateDatayAxis(String startTime) {
		return super.queryForList("qy_user_incr.SELECT_USE_RATE_DATA_YAXIS", startTime);
	}

	@Override
	public List<String> selectUseRateQoqDataxAxis(String startTime, String endTime, Integer base) {
		Map<String, Object> param = new HashMap<String, Object>();
		param.put("startTime", startTime);
		param.put("endTime", endTime);
		param.put("base", base);
		return super.queryForList("qy_user_incr.SELECT_USE_RATE_QOQ_DATA_XAXIS", param);
	}

	@Override
	public List<UserClientInfoUseRatio> selectUseRateQoqDatayAxis(String startTime, String endTime, Integer base, Integer carrier) {
		Map<String, Object> param = new HashMap<String, Object>();
		param.put("startTime", startTime);
		param.put("endTime", endTime);
		param.put("base", base);
		param.put("carrier", carrier);
		return super.queryForList("qy_user_incr.SELECT_USE_RATE_QOQ_DATA_YAXIS", param);
	}

	@Override
	public Long selectNewnumByCarrier(String rd, Integer carrier) {
		Map<String, Object> param = new HashMap<String, Object>();
		param.put("rd", rd);
		param.put("carrier", carrier);
		Integer num = super.queryForCount("qy_user_incr.SELECT_NEWNUM_BY_CARRIER", param);
		return num.longValue();
	}

}
